Skip to content

drivers: Standardize power on/off method naming.#148

Merged
nedseb merged 1 commit intomainfrom
fix/standardize-power
Mar 15, 2026
Merged

drivers: Standardize power on/off method naming.#148
nedseb merged 1 commit intomainfrom
fix/standardize-power

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 15, 2026

Closes #76

Summary

Standardize all power on/off methods to power_on() / power_off().

Changes

Driver Before After
apds9960 enable_power() / disable_power() power_on() / power_off()
bq27441 power_up() / power_down() power_on() / power_off()
hts221 power_on() / power_off() (unchanged)
ism330dl — / power_down() power_on() / power_off()
lis2mdl wake() / power_down() power_on() / power_off()
mcp23009e — / — power_on() / power_off() added (via RESET pin)
ssd1327 poweron() / poweroff() power_on() / power_off()
vl53l1x — / — power_on() / power_off() added (via SOFT_RESET register)
wsen-hids — / — power_on() / power_off() added (via PD bit)
wsen-pads — / power_down() power_on() / power_off()

Final state

Driver power_on() power_off()
apds9960
bq27441
hts221
ism330dl
lis2mdl
mcp23009e
ssd1327
vl53l1x
wsen-hids
wsen-pads

Also updated README, tests (8 new mock tests), examples, and driver READMEs.

Test plan

ruff check lib/                          # All checks passed
python3 -m pytest tests/ -k "mock" -v    # 111 passed

@nedseb nedseb force-pushed the fix/standardize-power branch 7 times, most recently from 1622f9d to cb1ebcb Compare March 15, 2026 11:22
@nedseb nedseb requested a review from Copilot March 15, 2026 11:23
@nedseb nedseb self-assigned this Mar 15, 2026
@nedseb nedseb added the enhancement New feature or request label Mar 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Standardizes driver power-management APIs across the repository by converging on power_on() / power_off(), and updates scenario tests/docs/examples accordingly to match the new names.

Changes:

  • Renamed inconsistent power methods across multiple drivers to power_on() / power_off().
  • Added new power_on() / power_off() implementations for some drivers and extended mock scenarios to validate behavior.
  • Updated README + driver READMEs + examples + YAML scenarios to use the standardized names.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
README.md Documents the new cross-driver power_on() / power_off() convention.
lib/apds9960/apds9960/device.py Renames enable_power() / disable_power() to power_on() / power_off().
lib/bq27441/bq27441/device.py Renames power_up() / power_down() to power_on() / power_off() and updates ctor call.
lib/ism330dl/ism330dl/device.py Renames power_down() to power_off() and introduces power_on().
lib/ism330dl/README.md Updates power-down documentation to power_off().
lib/lis2mdl/lis2mdl/device.py Renames wake()power_on() and power_down()power_off().
lib/lis2mdl/examples/magnet_test.py Updates example calls to new power method names (output text still needs alignment).
lib/lis2mdl/README.md Updates method overview table to power_on() / power_off().
lib/mcp23009e/mcp23009e/device.py Adds power_on() / power_off() using the RESET pin.
lib/ssd1327/ssd1327/device.py Renames poweron() / poweroff() to power_on() / power_off() and updates internal calls.
lib/vl53l1x/vl53l1x/device.py Adds power_on() / power_off() via the SOFT_RESET register.
lib/wsen-hids/wsen_hids/device.py Adds power_on() / power_off() based on the PD bit behavior.
lib/wsen-pads/wsen_pads/device.py Renames power_down() to power_off() and adds power_on(odr=...).
lib/wsen-pads/examples/test.py Updates example usage to power_off().
tests/scenarios/apds9960.yaml Updates scenario scripts to call power_off().
tests/scenarios/bq27441.yaml Updates scenario comments to reflect power_on() constructor behavior.
tests/scenarios/hts221.yaml Renames scenario titles to reference power_off.
tests/scenarios/ism330dl.yaml Updates scenario scripts to call power_off().
tests/scenarios/lis2mdl.yaml Updates scenario scripts to call power_off().
tests/scenarios/mcp23009e.yaml Adds mock scenarios validating reset-pin behavior for power_on/off.
tests/scenarios/ssd1327.yaml Adds mock smoke scenarios for power_on/off.
tests/scenarios/vl53l1x.yaml Adds mock scenarios validating SOFT_RESET writes for power_on/off.
tests/scenarios/wsen_hids.yaml Adds mock scenarios validating PD bit changes for power_on/off.
tests/scenarios/wsen_pads.yaml Updates scenario scripts to call power_off().
Comments suppressed due to low confidence (3)

lib/lis2mdl/examples/magnet_test.py:529

  • This example output string still references wake('continuous'), but the API has been renamed to power_on('continuous'). Update the printed label to avoid confusing users running the example.
    print(
        "wake('continuous') => MD=",
        md,
        "expected 0b00 =>",
        "OK" if md == 0b00 else "FAIL",
    )

lib/lis2mdl/examples/magnet_test.py:541

  • This example output string still references wake('single'), but the API has been renamed to power_on('single'). Update the printed label to match the new method name.
    print(
        "wake('single')      => MD=",
        md,
        "expected 0b01 =>",
        "OK" if md == 0b01 else "FAIL",
    )

lib/lis2mdl/examples/magnet_test.py:572

  • This example output string still references wake('continuous'), but the API has been renamed to power_on('continuous'). Update the printed label to match the new method name.
    print(
        "wake('continuous') => MD=",
        md,
        "expected 0b00 =>",
        "OK" if md == 0b00 else "FAIL",
    )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread lib/ism330dl/ism330dl/device.py
Comment thread lib/wsen-pads/wsen_pads/device.py
Comment thread lib/wsen-hids/wsen_hids/device.py Outdated
@nedseb nedseb force-pushed the fix/standardize-power branch from cb1ebcb to 6638f1d Compare March 15, 2026 12:57
@nedseb nedseb merged commit a8d40f7 into main Mar 15, 2026
3 checks passed
@nedseb nedseb deleted the fix/standardize-power branch March 15, 2026 12:58
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.0.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drivers: Standardize power on/off method naming.

2 participants